function ajax(url, param, async = true, mode = 99) {
    // 校验用户存在
    validateUser();
    $.ajax({
        type: "post",
        dataType: 'json',
        url: url,
        data: JSON.stringify(param),
        contentType: "application/json;charset=UTF-8",
        cache: false,
        async: async,
        success: function (data) {
            switch (mode) {
                case 1:
                    // dropdownRemoteViewList(data);
                    addResult(data);
                    break;
                case 2:
                    delResult(data);
                    break;
                case 3:
                    dropdownVersionList(data);
                    break;
                case 4:
                    scanModalDropdownRemoteViewList(data);
                    break;
                case 5:
                    scanResult(data);
                    break;
                default:
                    simpleResponse(data);
                    break
            }
        }
    });
}

function scanResult(data) {
    if (SUCCESS === data.RSPCD) {
        errorMsg("操作成功", type.SUCCESS);
        silenceRefresh("list");
        $('#myModal').modal('hide')
    } else {
        errorMsg(data.RSPMSG, type.DANGER)
    }
}
// function dropdownRemoteViewList(data) {
//     if (SUCCESS !== data.RSPCD) {
//         errorMsg(data.RSPMSG,type.DANGER)
//         return ;
//     }
//     let arr = data.BODY.LIST;
//     let append = "";
//     for (it of arr) {
//         append += "<option value=\""+it.ID+"\">"+it.NAME +"("+it.DESC+")</option>";
//     }
//     $("#add select[name=remote_view]").html(append);
// }


function dropdownVersionList(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER)
        return;
    }
    versionList = data.BODY.LIST;
    let append = "";
    for (it of versionList) {
        append += "<option value=\"" + it.VERSION + "\">" + it.VERSION + "(" + it.DESC + ")</option>";
    }
    $("#add select[name=version]").html(append);
}

// 扫描modal的下拉框,远程视图
function scanModalDropdownRemoteViewList(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER)
        return;
    }
    let arr = data.BODY.LIST;
    let append = "";
    for (it of arr) {
        append += "<option value=\"" + it.ID + "\">" + it.NAME + "(" + it.DESC + ")</option>";
    }
    $("#scan_form select[name=scan_service]").html(append);
}